//
//  TwoViewController.m
//  TransitionAnimation
//
//  Created by tgs on 2017/6/26.
//  Copyright © 2017年 tgs. All rights reserved.
//

#import "TwoViewController.h"
#import "TransitionObj.h"



@interface TwoViewController ()<UIViewControllerTransitioningDelegate>



@end

@implementation TwoViewController

- (instancetype)init{
    self = [super init];
    if (self) {
        self.transitioningDelegate = self;
        self.modalPresentationStyle = UIModalPresentationCustom;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor blueColor];
    
    UIButton *btnClickMe = [[UIButton alloc] initWithFrame:CGRectMake(50, 20, 120, 30)];
    [btnClickMe setTitle:@"点我dismiss" forState:UIControlStateNormal];
    [btnClickMe setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [self.view addSubview:btnClickMe];
    [btnClickMe addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
}


- (void)dismiss{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source{
    return [TransitionObj transitionWithTransitionType:PresentTransitionTypePresent];
}

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed{
    return [TransitionObj transitionWithTransitionType:PresentTransitionTypeDismiss];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
